/**
*	全局
**/
app.controller('gRefCtrl', ['$scope', '$state', '$stateParams', '$window', '$cookieStore', 'utils',
  function($scope, $state, $stateParams, $window, $cookieStore, utils) {

    // 后退
    $scope.goBack = function () {
      $window.history.back();
    }

    // 页面配置
    $scope.pageData = {
      loading: true,
      code: ''
    }



    utils.get('checkIfhasJoin', {
      openID: $cookieStore.get('openID') || ''
      // openID: '122'
    })
    .success(function functionName(rs) {
      if(rs.data ==false) {
        $state.go('g.join');
      } else {
        // 生成邀请码
        utils.get('getcode', {
          'openID': $cookieStore.get('openID') || ''
          // openID: '122'
        }).success(function (rs) {
          $scope.pageData.loading = false;
          $scope.pageData.code = rs.data;
        });

      }
    })



  }
]);
